﻿using MahApps.Metro.Controls;
using Metro.Demo.Model;
using Metro.Demo.Views;
using Prism.Mvvm;
using System;
using System.Collections.ObjectModel;
using System.Reflection.Metadata;
using Index = Metro.Demo.Views.Index;

namespace Metro.Demo.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private string _title = "智能力矩电批系统";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        public ObservableCollection<ThemeItem> _themes;
        public ObservableCollection<ThemeItem> Themes
        {
            get { return _themes; }
            set
            {
                SetProperty(ref _themes, value);
                RaisePropertyChanged("Themes");
            }
        }

        private ObservableCollection<MenuItem> _menus;

        public ObservableCollection<MenuItem> Menus
        {
            get { return _menus; }
            set
            {
                _menus = value;
                RaisePropertyChanged();
            }
        }


        public MainWindowViewModel()
        {
            Themes = new ObservableCollection<ThemeItem>()
            {
                new ThemeItem() { Name = "浅色-蓝", Key = "Light.Blue" },
                new ThemeItem() { Name = "深色-蓝", Key = "Dark.Blue" },
                new ThemeItem() { Name = "浅色-红", Key = "Light.Red" },
                new ThemeItem() { Name = "深色-红", Key = "Dark.Red" },
                new ThemeItem() { Name = "浅色-绿", Key = "Light.Green" },
                new ThemeItem() { Name = "深色-绿", Key = "Dark.Green" },
            };

            InitMenus();
        }

        private void InitMenus()
        {
            Menus = new ObservableCollection<MenuItem>
            {
                // 一级菜单
                new MenuItem
                {
                    Label = "工作台",
                    Icon = new FontIcon { Glyph = "\uE80F" },        // 图标
                    NavigationType = typeof(Index),               // 要导航到的 Page
                    NavigationDestination = new Uri("Views/Index.xaml", UriKind.Relative)
                },
                new MenuItem
                {
                    Label = "产品",
                    Icon = new FontIcon { Glyph = "\uE7BF" },
                    NavigationType = typeof(Product),
                    NavigationDestination = new Uri("Views/Product.xaml", UriKind.Relative)
                },
                new MenuItem
                {
                    Label = "记录",
                    Icon = new FontIcon { Glyph = "\uE8A5" },
                    NavigationType = typeof(Record),
                    NavigationDestination = new Uri("Views/Record.xaml", UriKind.Relative)
                },
                new MenuItem
                {
                    Label = "参数",
                    Icon = new FontIcon { Glyph = "\uE799" },
                    NavigationType = typeof(ParameterSet),
                    NavigationDestination = new Uri("Views/ParameterSet.xaml", UriKind.Relative)
                },
                new MenuItem
                {
                    Label = "设置",
                    Icon = new FontIcon { Glyph = "\uE713" },
                    NavigationType = typeof(Settings),
                    NavigationDestination = new Uri("Views/Settings.xaml", UriKind.Relative)
                },
                 new MenuItem
                {
                    Label = "用户",
                    Icon = new FontIcon { Glyph = "\uE716" },
                    NavigationType = typeof(UserManager),
                    NavigationDestination = new Uri("Views/UserManager.xaml", UriKind.Relative)
                }
            };
        }
    }
}
